﻿using System;
using System.Collections.Generic;

namespace ReportGenerator
{
    class ReportGenerator
    {
        private readonly EmployeeDB _employeeDb;

        public IPrinter Printer { set; get; }

        public ReportGenerator(EmployeeDB employeeDb)
        {
            if (employeeDb == null) throw new ArgumentNullException("employeeDb");
            _employeeDb = employeeDb;
        }

        public void CompileReport()
        {
            var employees = new List<Employee>();
            Employee employee;

            _employeeDb.Reset();

            // Get all employees
            while((employee = _employeeDb.GetNextEmployee()) != null)
            {
                employees.Add(employee);
            }

            try
            {
               Printer.Print(employees);
            }
            catch (Exception)
            {
               Console.WriteLine("No printer set for ReportGenerator");
            }
           
        }
    }
}
